﻿using System;
namespace yi
{
    public class Rectangle
    {
        public double length
        {
            get;
            set;
        }
        public double width
        {
            get;
            set;
        }
        public Rectangle() : this(0, 0)
        {

        }
        public Rectangle(double _length, double _width)
        {
            length = _length;
            width = _width;
        }
        public double area()
        {
            return length * width;
        }
        public double perimeter()
        {
            return (length + width) * 2;
        }
    }
    class 第一题
    {
        static void Main(string[] args)
        {
            double x, y;
            Console.WriteLine("请输入长方形的长：");
            bool p = double.TryParse(Console.ReadLine(), out x);
            Console.WriteLine("请输入长方形的宽：");
            bool q = double.TryParse(Console.ReadLine(), out y);
            if (p && q)
            {
                Rectangle r = new Rectangle(x, y);
                Console.WriteLine("长方形的周长为{0}", r.perimeter());
                Console.WriteLine("长方形的面积为{0}", r.area());
            }
            else
            {
                Console.WriteLine("数据输入有误！");
            }
        }
    }
}